package org.aeon.entity;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;

/**
 * @author: MissingAeon
 * @date: 2024/2/26 14:39
 * @description: 统计记录结构
 */
@Data
@NoArgsConstructor
public class StatisticsRecord {
    private String dateTime;
    private HashSet<Item> records;

    public StatisticsRecord(String dateTime) {
        this.dateTime = dateTime;
        records = new HashSet<>();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        StatisticsRecord that = (StatisticsRecord) o;
        return Objects.equals(dateTime, that.dateTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(dateTime);
    }

    @Data
    @NoArgsConstructor
    public static class Item {
        private Long target;
        private int count;

        public Item(Long target) {
            this.target = target;
            count = 0;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Item item = (Item) o;
            return Objects.equals(target, item.target);
        }

        @Override
        public int hashCode() {
            return Objects.hash(target);
        }
    }
}
